module.exports = options => {
    return (ctx, next) => {
        //禁止不合法的访问
        let path=ctx.path;
        let patt=/^(?:\/apiv1\/)+.+/;
        let res1=patt.test(path);


        let staticPatt=/^(?:\/uploads\/)+.+/;
        let res2=staticPatt.test(path);

        if(res1===false && res2===false)
        {
            ctx.body = '就是不让你用~';
            return false;
        }else{
            //跨域问题
            ctx.set({
                'Access-Control-Allow-Origin':'*',
                "Access-Control-Allow-Headers":'Content-Type,Content-Length,Authorization,Accept,X-Requested-With',
                "Access-Control-Allow-Methods": "PUT,POST,GET,DELETE,OPTIONS",
            });
            return next();
        }

    }
}